import Vue from 'vue';
import Router from 'vue-router';
const _import = require('./_import_' + process.env.NODE_ENV);
// in development env not use Lazy Loading,because Lazy Loading large page will cause webpack hot update too slow.so only in production use Lazy Loading

Vue.use(Router);

/* layout */
import Layout from '../views/layout/Layout';
import SubLayout from '../views/layout/SubLayout';

/**
 * icon : the icon show in the sidebar
 * hidden : if `hidden:true` will not show in the sidebar
 * redirect : if `redirect:noredirect` will no redirct in the levelbar
 * noDropdown : if `noDropdown:true` will has no submenu
 * meta : { role: ['admin'] }  will control the page role
 **/
export const constantRouterMap = [{
  path: '/login',
  component: _import('login/index'),
  hidden: true
},
{
  path: '/authredirect',
  component: _import('login/authredirect'),
  hidden: true
},
{
  path: '/404',
  component: _import('error/404'),
  hidden: true
},
{
  path: '/401',
  component: _import('error/401'),
  hidden: true
},
{
  path: '/',
  component: Layout,
  redirect: '/dashboard',
  name: '首页',
  hidden: true,
  children: [{
    path: 'dashboard',
    component: _import('dashboard/index')
  }]
},
{
  path: '/profile',
  component: Layout,
  redirect: '/profile/index',
  hidden: true,
  children: [
    {
      path: 'index',
      component: () => import('@/views/profile/index'),
      name: '个人资料',
      meta: { title: 'Profile', icon: 'user', noCache: true }
    }
  ]
},
{
  path: '/introduction',
  component: Layout,
  redirect: '/introduction/index',
  icon: 'form',
  noDropdown: true,
  children: [{
    path: 'index',
    component: _import('introduction/index'),
    name: '简述'
  }]
},
{
  path: '/shop',
  component: Layout,
  name: '商城管理',
  children: [
    {
      path: 'group',
      component: SubLayout,
      name: '分组',
      children: [{
        path: 'addGroup',
        component: _import('shop/goods/group/group/addGroup'),
        name: '添加分组'
      },
      {
        path: 'updateGroup',
        component: _import('shop/goods/group/group/updateGroup'),
        name: '修改分组'
      }]
    },
    {
      path: 'order',
      component: SubLayout,
      name: '订单',
      children: [{
        path: 'orderDetail',
        component: _import('shop/order/order/orderDetail'),
        name: '订单详情'
      },
      {
        path: 'refundDetail',
        component: _import('shop/order/refund/refundDetail'),
        name: '退款详情'
      }]
    },
    {
      path: 'shops',
      component: SubLayout,
      name: '店铺',
      children: [{
        path: 'addShops',
        component: _import('shop/shops/shops/addShops'),
        name: '新增店铺'
      },
      {
        path: 'updateShops',
        component: _import('shop/shops/shops/updateShops'),
        name: '编辑店铺'
      },
      {
        path: 'managementShops',
        component: _import('shop/shops/shops/managementShops')
      },
      {
        path: 'addBanner',
        component: _import('shop/shops/shops/shopsManage/shopsBanner/addBanner'),
        name: 'banner添加'
      },
      {
        path: 'updateBanner',
        component: _import('shop/shops/shops/shopsManage/shopsBanner/updateBanner'),
        name: 'banner修改'
      }
      ,
      {
        path: 'addComponen',
        component: _import('shop/shops/shops/shopsManage/shopComponen/addComponen'),
        name: '推荐位添加'
      }
      ,
      {
        path: 'updateComponen',
        component: _import('shop/shops/shops/shopsManage/shopComponen/updateComponen'),
        name: '推荐位修改'
      }
      ,
      {
        path: 'toPromotion',
        component: _import('shop/shops/shops/shopsManage/shopPromotion/toPromotion'),
        name: '查看推荐位模板'
      }
    ]
    }]
}
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({
    y: 0
  }),
  routes: constantRouterMap
});
//前端菜单栏目，栏目已经修改到后台获取，这里备份不用
export const asyncRouterMap = [{
  path: '/baseManager',
  component: Layout,
  name: '基础配置管理',
  icon: 'setting',
  authority: 'baseManager',
  children: [{
    path: 'userManager',
    icon: 'fa-user',
    component: _import('admin/user/index'),
    name: '用户管理',
    authority: 'userManager'
  }, {
    path: 'menuManager',
    icon: 'category',
    component: _import('admin/menu/index'),
    name: '菜单管理',
    authority: 'menuManager'
  }, {
    path: 'groupManager',
    icon: 'group_fill',
    component: _import('admin/group/index'),
    name: '角色权限管理',
    authority: 'groupManager'
  }, {
    path: 'groupTypeManager',
    icon: 'fa-users',
    component: _import('admin/groupType/index'),
    name: '角色类型管理',
    authority: 'groupTypeManager'
  }, {
    path: 'gateLogManager',
    icon: 'viewlist',
    component: _import('admin/gateLog/index'),
    name: '操作日志管理',
    authority: 'gateLogManager'
  }, {
    path: 'dictManager',
    icon: 'viewlist',
    component: _import('param/picklist/index'),
    name: '数据字典',
    authority: 'dictManager'
  }, {
    path: 'paramManager',
    icon: 'viewlist',
    component: _import('param/parameter/index'),
    name: '参数管理',
    authority: 'paramManager'
  }]
},
{
  path: '/msgManager',
  component: Layout,
  name: '短信管理',
  icon: 'setting',
  authority: 'msgManager',
  children: [{
    path: 'verifyCodeManager',
    icon: 'viewlist',
    component: _import('msg/verifyCode/index'),
    name: '验证码查询',
    authority: 'verifyCodeManager'
  }, {
    path: 'smsTempManager',
    icon: 'viewlist',
    component: _import('msg/template/index'),
    name: '短信模板管理',
    authority: 'smsTempManager'
  }, {
    path: 'smsHisManager',
    icon: 'viewlist',
    component: _import('msg/sms/index'),
    name: '短信记录查询',
    authority: 'smsHisManager'
  }]
},
{
  path: '/shopManager',
  name: '商城管理',
  component: Layout,
  icon: 'setting',
  authority: 'shopManager',
  children: [{
    path: '/goodManager',
    icon: 'setting',
    component: SubLayout,
    name: '商品',
    authority: 'goodManager',
    children: [{
      path: 'goodsGroupManager',
      icon: 'viewlist',
      component: _import('shop/goods/group/index'),
      name: '分组管理',
      authority: 'goodsGroupManager'
    }, {
      path: 'brandManager',
      icon: 'viewlist',
      component: _import('shop/goods/brand/index'),
      name: '品牌管理',
      authority: 'brandManager'
    },
    {
      path: 'categoryManager',
      icon: 'viewlist',
      component: _import('shop/goods/category/index'),
      name: '类别管理',
      authority: 'categoryManager'
    },
    {
      path: 'goodsManager',
      icon: 'viewlist',
      component: _import('shop/goods/goods/index'),
      name: '商品管理',
      authority: 'goodsManager'
    }]
  }, {
    path: 'merchantManager',
    icon: 'setting',
    component: SubLayout,
    name: '店铺管理',
    authority: 'merchantManager'
  }, {
    path: '/orderManager',
    icon: 'setting',
    component: SubLayout,
    name: '订单',
    authority: 'orderManager',
    children: [{
      path: 'shopOrderManager',
      icon: 'viewlist',
      component: _import('shop/order/order/index'),
      name: '订单管理',
      authority: 'shopOrderManager'
    },
    {
      path: 'shopOrderRefundManager',
      icon: 'viewlist',
      component: _import('shop/order/refund/index'),
      name: '退款维权',
      authority: 'shopOrderRefundManager'
    },
    {
      path: 'shopOrderCommentManager',
      icon: 'viewlist',
      component: _import('shop/order/comment/index'),
      name: '评价管理',
      authority: 'shopOrderCommentManager'
    }]
  }]
}];
